# import time
# from selenium import webdriver
# from selenium.webdriver import ActionChains
# from selenium.webdriver.common.by import By
#
# # 创建浏览器驱动对象
# driver = webdriver.Edge()
# # 创建鼠标操作对象
# action = ActionChains(driver)
# # 打开网址
# driver.get("file:///D:/pagetest/注册A.html")
# # 悬停到菜单
# driver.find_element(By.XPATH,'/html/body/div[1]/ul/li').click()
# # 点击 打开豆瓣
# driver.find_element(By.CSS_SELECTOR,'#itemC').click()
#
# # 搜索框内 输入你喜欢的电影
#
# # 点击搜索
#
# # 点击第一个内容
# time.sleep(60)
# driver.quit()

import time
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.remote import switch_to
driver = webdriver.Edge()
# 打开 pagetest目录下的 page 目录的 注册实例
driver.get('file:///D:/pagetest/page/注册实例.html')
time.sleep(3)
# 在左下 注册用户A 内
# 输入 账号     王大锤
# 输入 密码     123456
driver.switch_to.frame('idframe1')
driver.find_element(By.CSS_SELECTOR,'#userA').send_keys('王大锤')
time.sleep(3)
driver.find_element(By.CSS_SELECTOR,'#passwordA').send_keys('123456')
# time.sleep(3)
# 在右下 注册用户B 内
# 输入 账号     王心凌
driver.switch_to.default_content()
driver.switch_to.frame('myframe2')
driver.find_element(By.CSS_SELECTOR,'#userB').send_keys('王心凌')
# time.sleep(3)
# 输入 密码     654321
driver.find_element(By.CSS_SELECTOR,'#passwordB').send_keys('654321')
time.sleep(3)

# 在上边 注册用户 内
# 输入 账号     王宝强
driver.switch_to.default_content()
driver.find_element(By.CSS_SELECTOR,'#user').send_keys('王宝强')
# time.sleep(3)
# 输入 密码     abcde
driver.find_element(By.CSS_SELECTOR,'#password').send_keys('abcde')
# time.sleep(3)
# 点击 注册A页面
driver.find_element(By.CSS_SELECTOR,'#ZCA').click()
# time.sleep(3)
# 进入注册A页面后 点击    访问 新浪 网站
a = driver.window_handles[1]
driver.switch_to.window(a)
driver.find_element(By.LINK_TEXT,'访问 新浪 网站').click()
# time.sleep(3)
# 进入新浪网后 点击 搜索框
a = driver.window_handles[2]
driver.switch_to.window(a)
driver.find_element(By.CSS_SELECTOR,'body > div.top-search-wrap > div > div.top-search.clearfix > form > div.inp-txt-wrap > input').click()
time.sleep(3)
# 在搜索框内 输入 iphone16
driver.find_element(By.NAME,'SerchKey').send_keys('iphone16')
time.sleep(3)
# 点击搜索
time.sleep(500)
driver.quit()





































